//
//  SwitchHeadImageWindowController.m
//  HiQ
//
//  Created by arvintan on 12-8-2.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "SwitchHeadImageWindowController.h"

@interface SwitchHeadImageWindowController ()

@end

@implementation SwitchHeadImageWindowController

@synthesize _headImage;

@synthesize _buttonHeadImage1;
@synthesize _buttonHeadImage2;
@synthesize _buttonHeadImage3;
@synthesize _buttonHeadImage4;
@synthesize _buttonHeadImage5;
@synthesize _buttonHeadImage6;

- (id)initWithWindow:(NSWindow *)window
{
    self = [super initWithWindow:window];
    if (self) {
        // Initialization code here.
    }
    
    return self;
}
- (void)windowDidLoad
{
    [super windowDidLoad];
    // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}

-(void) awakeFromNib
{
    _headImage = [NSImage imageNamed:@"H1"];
    [_buttonHeadImage1 setImage:_headImage];
    _headImage = [NSImage imageNamed:@"H2"];
    [_buttonHeadImage2 setImage:_headImage];
    _headImage = [NSImage imageNamed:@"H3"];
    [_buttonHeadImage3 setImage:_headImage];
    _headImage = [NSImage imageNamed:@"H4"];
    [_buttonHeadImage4 setImage:_headImage];
    _headImage = [NSImage imageNamed:@"H5"];
    [_buttonHeadImage5 setImage:_headImage];
    _headImage = [NSImage imageNamed:@"H6"];
    [_buttonHeadImage6 setImage:_headImage];
}

-(NSImage*) headImage:(NSWindowController *)sender
{
    //用sheet的方式显示窗体，并返回选择结果
    NSWindow *window = [self window];
    [NSApp beginSheet:window
       modalForWindow:[sender window]
        modalDelegate:nil
       didEndSelector:nil
          contextInfo:nil];
    [NSApp runModalForWindow:window];
    
    [NSApp endSheet:window];
    [window orderOut:self];
    
    return _headImage;
}

#pragma mark -
#pragma mark button action

-(IBAction)onClicked1:(id)sender
{
    _headImage = [NSImage imageNamed:@"H1"];
    [NSApp stopModal];
}

-(IBAction)onClicked2:(id)sender
{
    _headImage = [NSImage imageNamed:@"H2"];
    [NSApp stopModal];
}

-(IBAction)onClicked3:(id)sender
{
    _headImage = [NSImage imageNamed:@"H3"];
    [NSApp stopModal];
}

-(IBAction)onClicked4:(id)sender
{
    _headImage = [NSImage imageNamed:@"H4"];
    [NSApp stopModal];
}

-(IBAction)onClicked5:(id)sender
{
    _headImage = [NSImage imageNamed:@"H5"];
    [NSApp stopModal];
}

-(IBAction)onClicked6:(id)sender
{
    _headImage = [NSImage imageNamed:@"H6"];
    [NSApp stopModal];
}

@end
